﻿<%@ WebHandler Language="C#" Class="viewOwerInfo" %>

using System;
using System.Web;
using System.Text;
using System.Collections.Generic;
using System.Web.Script.Serialization;
using Chenxin.Lib.Utility;

public class viewOwerInfo : AjaxHandlerBase
{

    //*******************************************
    //功能概要       ：重写的请求处理方法
    //参数説明       ：context 请求的上下文
    //返回值説明     ：无
    //功能詳細       ：父类中隐藏了IHttpHandler接口方法，本类中须对本方法进行重写
    //作成者         ：姚志强
    //作成日         ：2010-03-04 
    //修改者         ：王玮
    //修改日         ：2010-03-25
    //*******************************************
    override public void RequestProcess(HttpContext context)
    {
        context.Response.AddHeader("pragma", "no-cache");
        context.Response.AddHeader("cache-control", "");
        context.Response.CacheControl = "no-cache";
        
        string strOp = context.Request["op"];
        string strResponse = "";
        switch (strOp.ToLower())
        {
            case "view":
                strResponse = ViewOwnerInfo(context);
                break;
            default:
                break;
        }
        context.Response.Write(strResponse);
    }

   
    //*******************************************
    //功能概要       ：添加查看信息的人
    //参数説明       ：
    //返回值説明     ：
    //功能詳細       ：添加查看信息的人
    //作成者         ：姚志强
    //作成日         ：2010-03-03
    //修改者         ：
    //修改日         ：
    //*******************************************
    private string ViewOwnerInfo(HttpContext context)
    {
        try
        {
            //转换成实体
            Chenxin.Lib.House.Entity.House_BaseInfo model = (Chenxin.Lib.House.Entity.House_BaseInfo)Chenxin.Lib.Utility.JsonHelp.Convert2Entity(context.Request["model"], typeof(Chenxin.Lib.House.Entity.House_BaseInfo));
            if (model.HouseId == null)
                return string.Format("{{success:'0',msg:'{0}：{0}',data:''", "房源标识丢失，请联系管理员！");
            
            Chenxin.Lib.House.Entity.House_ViewOwerInfo viewOwnerInfo = new Chenxin.Lib.House.Entity.House_ViewOwerInfo();
            Chenxin.Lib.House.Entity.House_BaseInfo houseinfo = Chenxin.Lib.House.DAL.House_BaseInfo.GetModel(model.HouseId);

            viewOwnerInfo.RecordId = Guid.NewGuid();
            viewOwnerInfo.HouseId = model.HouseId;
            viewOwnerInfo.HouseCode = houseinfo.HouseCode;
            viewOwnerInfo.HouseAddress = houseinfo.Community + houseinfo.BuildingName + houseinfo.Room;
            viewOwnerInfo.ViewEmployeeId = CurrentUserInfo.UserId;
            viewOwnerInfo.Employee = CurrentUserInfo.UserName;
            viewOwnerInfo.ViewDepartId = CurrentUserInfo.DepartId;
            viewOwnerInfo.Depart = CurrentUserInfo.DepartName;
            viewOwnerInfo.Addtime = DateTime.Now;
            Chenxin.Lib.House.BLL.House_BaseInfo.AddViewOwnerInfo(viewOwnerInfo);
            return string.Format("{{success:'1',msg:'{0}',data:''", "");
       }
        catch (Exception ex)
        {
            return string.Format("{{success:'0',msg:'意外错误：{0}',data:''", ex.Message);
        }
    }
}